# -*-codeing = utf-8 -*-
# @Tine:2024/9/19 
# @Author:计科201121尚益帆
# File：4.2.py
# @Software:PyCharm
# 读取 a.txt 中的文本并打印到屏幕上
with open('a.txt', 'r') as file:
    content = file.read()
    print(content)

# 写入一段文本到 b.txt 中
text_to_write = "这是一段要写入 b.txt 的文本。"
with open('b.txt', 'w') as file:
    file.write(text_to_write)


text_to_write = "222This is the second line."
# 设置为写入模式
file = open('b.txt', 'w')
# 写入文本
file.write("111")
file.close()
# 文件已关闭
